package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealOverViewVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    /*
    * 套餐的分页查询
    * */
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    /*
    * 根据id查询套餐信息
    * */
    @Select("select * from setmeal where id = #{id}")
    SetmealVO selectSetmealById(Long id);

    /*
    * 根据id查询套餐内的菜品信息
    * */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> selectSetmealDishById(Long id);

    /*
    * 新增套餐
    * */
    @AutoFill(OperationType.INSERT)
    void save(Setmeal setmeal);

    /*
    * 修改套餐的基本信息
    * */
    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    /*
    * 根据id删除套餐
    * */
    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Long id);

    /*
    * 根据id查询套餐状态
    * */
    @Select("select status from setmeal where id = #{id}")
    Integer getStatusByIds(Long id);

    /*
    * 根据分类id查询套餐
    * */
    List<Setmeal> list(Setmeal setmeal);

    /*
    * 根据套餐id查询菜品
    * */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<DishItemVO> getDishItemById(Long id);

    /**
     * 菜品起售和停售的数量
     * @return com.sky.vo.SetmealOverViewVO
     * @author zhupp
     * @create 2025/3/1
     **/
    Integer getSetmealsByStatus(Integer status);
}
